<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>自行接收</title>
<link href="/static/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/static/css/cb.css" rel="stylesheet" type="text/css" />
<link href="/static/css/n.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css"
	href="/static/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/demo/demo.css" />
<link rel="stylesheet" type="text/css"
	href="/static/js/laypage/skin/laypage.css" />

<script type="text/javascript" src="/static/easyui/jquery.min.js"></script>
<script src="/static/js/vue/vue.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/js/laypage/laypage.js"></script>
<script type="text/javascript" src="/static/js/layer/layer.js"></script>
<script type="text/javascript" src="/static/laydate/laydate.js"></script>
<script type="text/javascript" src="${request.contextPath}/static/easyui/locale/easyui-lang-zh_CN.js"></script> <#--comcn155 修改删除提示框语言-->
<script type="text/javascript" src="${request.contextPath}/static/js/work-mange.js"></script> <#--comcn155 输入框输入提示信息-->
<script type="text/javascript" src="/static/js/examine.js"></script> <#--comcn155 引用封装批量方法-->


</head>
<body>
	<div id="app" style="width:1700px;height: 740px;overflow: scroll;"> <#--comcn155 添加滚动条-->
		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table width="124"
						border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">查找待入矫人员</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="3"
			cellspacing="1" bgcolor="#AEDEF4">
			<tr>
				<td align="center" bgcolor="#E2F7FE">

					<form id="form1" name="form1" method="post" action="">
						<table width="100%" border="0" cellspacing="1" cellpadding="3">
							<tr>
								<td width="5%" align="right">协管单位:</td>
								<td width="5%" align="left"><select name="unitchoice"
									value="请选择矫正单位" style="width: 106px; height: 18px" id="jname">
										<option value="">任意</option>
										<option v-for="(item,index) in result1" :value="item.name">{{item.name}}</option>
								</select></td>
								<td width="5%" align="right">姓名:</td>
								<td width="5%" align="left"><select id="cname" style="width: 106px; height: 18px">
									<#--<input name="name" type="text" id="cname" size="15" />-->
									<option value="">任意</option>
									<option v-for="(item,index) in result2" :value="item.name">{{item.name}}</option></select>
								</td>
								<td width="5%" align="right">性别:</td>
								<td width="5%" align="left"><select name="unitchoice"
									value="请选择性别" style="width: 106px; height: 18px" id="sex">
										<option value="">任意</option>
										<option value="男">男</option>
										<option value="女">女</option>
								</select></td>
								<td width="5%" align="right">证件号码:</td>
								<td width="5%" align="left"><input name="name" type="text"
									id="papersnum" size="15" /></td>
								<td width="5%" align="right">刑罚类别:</td>
								<td width="5%" align="left"><select name="zx_type"
									style="width: 106px; height: 18px" id="zx_type">
										<option value="">任意</option>
										<option value="有期徒刑">有期徒刑</option>
										<option value="管制">管制</option>
										<option value="拘役">拘役</option>
										<option value="无期徒刑">无期徒刑</option>
										<option value="死刑">死刑</option>
								</select></td>
								<td width="5%" align="right">监管级别:</td>
								<td width="5%" align="left"><select name="jg_rank"
									style="width: 106px; height: 18px" id="jg_rank">
										<option value="">任意</option>
										<option value="普管">普管</option>
										<option value="一级宽管">一级宽管</option>
										<option value="二级宽管">二级宽管</option>
										<option value="严管">严管</option>
								</select></td>
								<td width="5%" align="right">矫正起止:</td>
								<td width="5%" align="left"><input placeholder="请选择日期"
									class="laydate-icon" onclick="laydate()" id="j_startdate" /> <input
									placeholder="请选择日期" class="laydate-icon" onclick="laydate()"
									id="j_enddate" /></td>
								<td width="2%" align="left"><input type="button"
									id="checkButton" value="查找" /></td>
								<td width="5%" colspan="2" align="right"><input
									type="button" onclick="addEvent()" name="" value="增加记录" /> <input
									type="button" onclick="download()" name="" value="导出Excle" /></td>
							</tr>
						</table>
					</form>
				</td>
			</tr>
		</table>

		<table width="50%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="5"></td>
			</tr>
		</table>

		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table width="124"
						border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">待入矫人员列表</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="3"
			cellspacing="1" style="border: 1px solid #AEDEF4">
			<tr bgcolor="#D6F2FD">
				<td align="center"><input name="allcheck" id="allcheck" value="" type="checkbox" /></td> <#--comcn155 改动复选框位置-->
				<td width="5%" height="25" align="center" >序号</td>
				<td align="center" >矫正单位</td>
				<td align="center" >姓名</td>
				<td align="center" >性别</td>
				<td align="center" >证件号码</td>

				<td align="center" >刑罚类别</td>
				<td align="center" >监管级别</td>
				<td align="center" >状态</td>
				<td align="center" >管理操作</td>
			</tr>
			<tr v-for="(item,index) in result"
				onmouseout="this.style.backgroundColor='#ffffff'" bgcolor="#ffffff"
				onmouseover="this.style.backgroundColor='#E6F2FF'">
                <td align="center"><input name="check" :value="item.id" type="checkbox" /></td> <#--comcn155 :value获得id属性-->
				<td height="25" align="center">{{index+1}}</td> <#--comcn155 把序号调整为行号-->
				<td align="center" class="t5"><div align="center">
						<strong>{{item.jname}}</strong>
					</div></td>
				<td align="center">{{item.name}}</td>
				<td align="center">{{item.sex}}</td>
				<td align="center">{{item.papersnum}}</td>
				<td align="center">{{item.zx_type}}</td>
				<td align="center">{{item.jg_rank}}</td>
				<td align="center">{{item.state}}</td>
				<td align="left">
					<div align="left" style="padding-left: 5px">
						<div align="center">
							<input type="button" @click="checkEvent(item.id)" name=""
								value="查看" /> <input type="button" @click="editEvent(item.id)"
								name="" value="修改" /> <input type="button"
								@click="delEvent(item.id)" name="" value="删除" />
						</div>
					</div>
				</td>
			</tr>

			<tr>
				<td colspan="6" align="center">
					<div id="pagediv"></div>
				</td>
				<td><input type="button" value="批量导出" onclick="exportchoice('correctedPerson')"/></td> <#--comcn155 添加批量删除导出功能按钮-->
				<td><input type="button" value="批量删除" onclick="alldelete('correctedPerson')"/></td>
			</tr>
		</table>
		<!-- 增加待入矫人员出框 -->
		<div id="dlg" style="background-color: #AEDEF4"></div>
		<!-- 查看待入矫人员出框 -->
		<div id="dlg1" style="background-color: #AEDEF4"></div>
		<!-- 修改待入矫人员出框 -->
		<div id="dlg2" style="background-color: #AEDEF4"></div>
	</div>
	<!-- js代码控制增删改查弹出层 -->
	<script type="text/javascript">
		var app = new Vue({
			el : '#app',
			data : {
				result : [],
				result1 : [],
				result2 : []
			}
		});
		//导出Excel
		function download() {
			var url = "/correctedPerson/exportExcel";
			window.open(url);
		}
		//模糊查询分页列表
		var getPageList = function(curr) {
			$.ajax({
				type : "get",
				dataType : "json",
				url : "/correctedPerson/querylike",
				data : {
					pageNum : curr || 1,
					pageSize : 20,
					jname : $("#jname").val(),
					name : $("#cname").val(),
					sex : $("#sex").val(),
					papersnum : $("#papersnum").val(),
					zx_type : $("#zx_type").val(),
					jg_rank : $("#jg_rank").val(),
					startdate : $("#j_startdate").val(),
					enddate : $("#j_enddate").val()

				},
				//显示分页
				success : function(data) {
					app.result = data.page.result;
					app.result1 = data.judicialDeptment;
					app.result2= data.correctedPerson;
					laypage({
						cont : 'pagediv', //容器。值支持id名、原生dom对象，jquery对象,
						pages : data.page.totalPage, //总页数
						first : "首页",
						last : "尾页",
						skip : true, //是否开启跳页
						skin : '#5675A2',
						curr : curr || 1, //当前页
						jump : function(obj, first) { //触发分页后的回调
							if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
								getPageList(obj.curr);
							}
						}
					});
				}
			});
		}



		//获取待入矫人员记录列表
		getPageList();

		//查询
		$("#checkButton").on('click', function() {
			getPageList();
		})
		//查看待入矫人员信息
		var checkEvent = function(id) {
			$('#dlg1').dialog({
				title : '查看---违规违纪记录详情',
				width : 1320,
				height : 800,
                left: 200,  /*comcn155调整间距，处理滚动条bug*/
                top: 50,
                minimizable:true,
                maximizable:true,
                resizable:true,
                closed : false,
				cache : false,
				href : '/correctedPerson/getAll?id=' + id,
				modal : true,
				buttons : [ {
					text : '关闭',
					handler : function() {
						$('#dlg1').dialog('close');
					}
				} ]
			});
		}

		//删除违规违纪记录
		var delEvent = function(id) {
			$.messager.confirm('提示框', '你确定要删除吗?', function(res) {
				if (res) {
					$.ajax({
						url : "/correctedPerson/delAll?id=" + id,
						type : "get",
						dataType : "json",
						data : {
							id : id
						},
						success : function(result) {
							$.messager.alert({
								title : '消息',
								msg : '删除成功!',
								icon : 'info'
							});
							getPageList();
						}
					});
				} else {
					//取消删除
				}
			})
		}
		//增加入矫人员信息
		var addEvent = function() {
			$('#dlg').dialog({
				title : '增加---待入矫人员',
				width : 1320,
				height : 800,
				left: 200,
				top: 50,
                minimizable:true,
                maximizable:true,
                resizable:true,
                closed : false,
				cache : false,
				href : '/correctedPerson/preAdd',
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
					    if($("#form3").form('validate')){ /*comcn155 jquery表单验证*/
                            var formData = new FormData($("#form3")[0]);
                            console.log(formData);
                            $.ajax({
                                url : '/correctedPerson/addAll',
                                type : 'POST',
                                data : formData,
                                async : false,
                                cache : false,
                                contentType : false,
                                processData : false,
                                success : function(res) {
                                    $.messager.alert({
                                        title : '消息',
                                        msg : '保存成功!',
                                        icon : 'info'
                                    });
                                    getPageList();
                                    $('#dlg').dialog('close');
                                }
                            });
                        }
                    }
				}, {
					text : '关闭',
					handler : function() {
						$('#dlg').dialog('close');
					}
				} ]
			});
		}
		//修改待入矫人员信息
		var editEvent = function(id) {
			$('#dlg2').dialog({
				title : '修改---入矫人员信息记录详情',
				width : 1320,
				height : 800,
				closed : false,
				cache : false,
                minimizable:true,
                maximizable:true,
                resizable:true,
                href : '/correctedPerson/getAllEdit?id=' + id,
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
						var formData = new FormData($("#form2")[0]);
						console.log(formData);
						$.ajax({
							url : "/correctedPerson/editPer",
							type : "post",
							dataType : "json",
							async : false,
							cache : false,
							contentType : false,
							processData : false,
							data : formData,
							success : function(result) {
								$.messager.alert({
									title : '消息',
									msg : '修改成功!',
									icon : 'info'
								});
								getPageList();
								$('#dlg2').dialog('close');
							}
						});
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#dlg2').dialog('close');
					}
				} ]
			});

		}

        // 批量删除所选
        function alldelete(sort) {
            //获取所有name为check的复选框的数组
            var id = document.getElementsByName("check");
            //定义一个数组
            var ids = [];
            //定义一个变量,记录选中的复选框个数
            var i = 0;
            //遍历数组id
            for (k in id) {
                //取选中的复选框的value属性,赋值给ids数组
                if (id[k].checked) {
                    i++;
                    ids.push(id[k].value);
                }
            }
            //如果选中的复选框数大于0,提示删除
            if (i > 0) {
                $.messager.confirm('提示框', '你确定要删除' + i + '条数据吗?',
                        function(res) {
                            if (res) {
                                $.ajax({
                                    url: "/" + sort + "/getDeleteIds",
                                    traditional: true,
                                    type: "get",
                                    dataType: "text",
                                    data: {
                                        id: ids
                                    },
                                    success: function(result) {
                                        $.messager.alert({
                                            title: '消息',
                                            msg: '删除' + i + '条数据成功!',
                                            icon: 'info'
                                        });
                                        $("input[name='check']").prop("checked", false);
                                        $("input[name='allcheck']").prop("checked", false);
                                        getPageList();
                                    }
                                })
                            } else {
                                // 取消删除
                            }
                        })
                //如果选中的复选框数小于0,提示未选中复选框
            } else {
                $.messager.alert({
                    title: '消息',
                    msg: '请至少选择一项!',
                    icon: 'info'
                });
            }
        }

        // 批量导出所选
        function exportchoice(sort) {
            var id = document.getElementsByName("check");
            var ids = [];
            var i = 0;
            for (k in id) {
                if (id[k].checked) {
                    i++;
                    ids.push(id[k].value);
                }
            }
            if (i > 0) {
                $.messager.confirm('提示框', '你确定要导出' + i + '条数据吗?',
                        function(res) {
                            if (res) {
                                var url = "/"+sort+"/exportExcel?id=" + ids;
                                window.open(url);
                                $("input[name='check']").prop("checked", false);
                                $("input[name='allcheck']").prop("checked", false);
                            } else {
                                // 取消删除
                            }
                        })
            } else {
                $.messager.alert({
                    title: '消息',
                    msg: '请至少选择一项!',
                    icon: 'info'
                });
            }
        }

	</script>

</body>
</html>